package com.linkage.educloud.ah.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mr'Tang on 2018/12/18.
 */

public class ResClassifyMeta {
    private int classifyType;
    private List<ResClassify> resClassifies;

    public static List<ResClassifyMeta> fromJSONObject(JSONArray jar) {
        List<ResClassifyMeta> list = new ArrayList<>();
        for (int i = 0; i < jar.length(); i++) {
            try {
                JSONObject obj = jar.getJSONObject(i);
                ResClassifyMeta meta = new ResClassifyMeta();
                meta.setClassifyType(obj.getInt("grouptype"));
                if (obj.has("resdata")) {
                    meta.setResClassifies(ResClassify.parseFromJson(obj.getJSONArray("resdata")));
                }
                list.add(meta);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return list;
    }

    public int getClassifyType() {
        return classifyType;
    }

    public void setClassifyType(int classifyType) {
        this.classifyType = classifyType;
    }

    public List<ResClassify> getResClassifies() {
        return resClassifies;
    }

    public void setResClassifies(List<ResClassify> resClassifies) {
        this.resClassifies = resClassifies;
    }
}
